<?php session_start();
            $con = mysql_connect("localhost","root","");
            if (!$con)
            {
                die('Could not connect: ' . mysql_error());
            }

            mysql_select_db("progin_171_13509008", $con);

            // get session id_content which we want to display
            $id_temp = $_SESSION['id_content'];
            global $nowid;
            $queryDetilContent = "Select content.id_content as id_konten,content.title, content.content_type, content.content_filled, content.posting_time, content.content_description, user_name from content inner join (select most_comment.id_content as id_most_commented from (select id_content, count(*) as result from comment group by id_content order by result Desc) as most_comment)  comment_result
on content.id_content = comment_result.id_most_commented limit 3;";
            $resultSelect = mysql_query($queryDetilContent);

            
            while ($row = mysql_fetch_array($resultSelect)){
                if($row['content_type']== 'link'){
                    echo "<h1>".$row['title']."</h1>";
                    echo "<h2>".$row['content_filled']."</h2>";
                    echo "<h3>".$row['content_description']."</h3>";
                    echo "<h3>Posted by: <a href='detail.php'>".$row['user_name']."</a></h3>";
                }
                if($row['content_type']== 'image'){
                    echo "<h1>".$row['title']."</h1>";
                    echo "<img src='".$row['content_filled']."' height=500px width=this.width; ></img>";
                    echo "<h3>Posted by: <a href='detail.php'>".$row['user_name']."</a></h3>";
                }
                if($row['content_type']== 'video'){
                    echo "<h1>".$row['title']."</h1>";
                    echo $row['content_filled'];
                    echo "<h3>Posted by: <a href='detail.php'>".$row['user_name']."</a></h3>";
                }
                echo "<br><br>";
                echo "<div id=infolikes>";
                 echo"<input id='like_".$row['id_konten']."' class='like_button' type='image' src='images/like_button.jpg' onclick='like(\"".$_SESSION['user_name']."\",".$row['id_konten'].")' style='float:left;'/>";
                   echo"<input class='total_like_class' type='text' disabled='disabled' id='total_like_".$row['id_konten']."'  />";
                   echo"<input id='dislike_'".$row['id_konten']." class='like_button' type='image' src='images/dislike_button.jpg' onclick='dislike(\"".$_SESSION['user_name']."\",".$row['id_konten'].")'/>";
                   echo"<input class='total_dislike_class' type='text' disabled='disabled' id='total_dislike_".$row['id_konten']."'/>";
                  echo "</div>";
                      echo"<script type='text/javascript'>"; //hitung nilai like dan dislike dulu!
                   echo "likeUpdater(".$row['id_konten']."); dislikeUpdater(".$row['id_konten'].");";
                   echo "</script>";
                   $nowid = $row['id_konten'];
            }

            // show time Posting
            $queryGetTime = "SELECT CONCAT(
                                FLOOR(HOUR(TIMEDIFF(posting_time, NOW())) / 24), ' days ',
                                MOD(HOUR(TIMEDIFF(posting_time, NOW())), 24), ' hours ',
                                MINUTE(TIMEDIFF(posting_time, NOW())), ' minutes') as time_difference
                                from content where id_content=$nowid";
            $resultTime= mysql_query($queryGetTime);

            while ($rowres = mysql_fetch_array($resultTime)){
                echo "Posting Time:  ".$rowres['time_difference']." ago";
            }

            ?>

